package com.fupan.Simple;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SimpleMq {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendMessage(){    //发送消息
        rabbitTemplate.convertAndSend("simpleQueue","send a message to mq a simple queue!");
    }


    public void receiveMessage(){  //手动接收消息
        Object simpleQueue = rabbitTemplate.receiveAndConvert("simpleQueue");
        System.out.println(simpleQueue.toString());
    }
}
